<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <button>发送请求</button>
        <button>取消请求</button>

        <script type="text/javascript">
            const btns = document.querySelectorAll("button");
            let xhr = null;
            btns[0].onclick = function(){
                xhr = new XMLHttpRequest();
                xhr.open("get","http://127.0.0.1:8000/delay");
                xhr.send();
            }
            //abort取消请求
            btns[1].onclick = function(){
                xhr.abort();
            }
        
        
        
        </script>
    </body>
</html>